<template>
  <div class="packageOrdersList">
    <div class="number-big">
      <div class="number">套餐总席位：2</div>
      <div class="number">总在线：2</div>
    </div>
    <div class="table-big">
      <div class="formGroup">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="130px" class="">
          <el-popover
            placement="top-start"
            width="200"
            trigger="hover"
           >
            <div class="qrCode">
              <div class="title"><img src="@/assets/images/wx.png"/>专属客服</div>
              <img src="@/assets/images/kefu.png" class="qrCode-img"/>微信扫码添加客服</div>
            <el-button v-hasPermi="['system:packageorders:add']" slot="reference" type="primary" size="small" style="margin-right: 10px"><i class="el-icon-plus"></i>增加席位</el-button>
          </el-popover>

          <el-form-item prop="userName2">
            <el-select v-model="queryParams.userName2" size="small" filterable placeholder="订单类型" @change="handleQuery">
              <el-option
                v-for="item in userList"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="userName2">
            <el-select v-model="queryParams.userName2" size="small" filterable placeholder="订单状态" @change="handleQuery">
              <el-option
                v-for="item in userList"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item prop="userName2">
            <div class="search">
              <el-input v-model="queryParams.userName1" size="small" placeholder="搜索订单编号" clearable/>
              <el-button icon="el-icon-search" size="small" @click="handleQuery"></el-button>
            </div>
          </el-form-item>
        </el-form>
      </div>
      <div class="tableAnalysis">
        <el-table
          :data="tableDataList"
          ref="customerMgtList"
        >
          <el-table-column
            :label="item.label"
            align="center"
            v-for="(item, index) in tableColumns"
            :key="index"
            :prop="item.key"
            :min-width="item.minWidth ? item.minWidth : ``"
            :fixed="item.fixed ? item.fixed : false"
            :show-overflow-tooltip="true"
          >
            <!--用于表格自定义-->
            <template slot="header" v-if="item.showHeaderTip">
              <div>
                {{ item.label }}
                <el-tooltip effect="dark" :content="item.showHeaderTip" placement="top">
                  <span><i class="el-icon-question"></i></span>
                </el-tooltip>
              </div>
            </template>
            <template slot-scope="scope">
              <div v-if="item.key=='status'" class="status red">生效中</div>
              <div v-else >{{ scope.row[item.key] }}</div>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>

  </div>
</template>
<script>
import {listUser} from "@/api/system/user";
import {getTime} from "@/utils";

export default {
  name: "packageOrdersList",
  components: {
  },
  data() {
    return {
      showSessionDetails: false,
      queryParams: {},
      userList: [
        {
          value: '1',
          label: '员工1'
        }, {
          value: '2',
          label: '员工2'
        }
      ],
      tableHeight: 600,
      tableColumns: [
        {key: 'name', label: `订单编号`, visible: true, minWidth: 150, fixed: true},
        {key: 'mobile', label: `订单类型`, visible: true, minWidth: 150, fixed: false,},
        {key: 'email', label: `席位数`, visible: true, minWidth: 200,},
        {key: 'last_login_time', label: `增值内容`, visible: true, minWidth: 200,},
        {key: 'create_time', label: `生效时间`, visible: true, minWidth: 200,},
        {key: 'check_payCreate_time', label: `到期时间`, visible: true, minWidth: 200,},
        {key: 'status', label: `订单状态`, visible: true, minWidth: 200,},
      ],
      tableDataList: [],
      total: 8, // 表格的总条数
    }
  },
  watch: {},
  created() {
    //this.getList();
    this.tableDataList = [];
     for (let i=0 ;i<3;i++){
       let obj={
         name:'2023-12-12',
         mobile:0,
         email:0,
         last_login_time:0,
         create_time:0,
         check_payCreate_time:0,
         status:'生效中',
       }
       this.tableDataList.push(obj);
     }
  },
  methods: {
    getValue(obj) {
      console.log('获取行', obj);
    },
    handleView() {
      this.showSessionDetails = true;
    },
    getTime(type) {
      this.selectedRange = type;
      setTimeout(() => {
        console.log('时间范围', this.dateRange);
        this.timeRange = [];
        this.timeRange = [this.fiterTime(this.dateRange[0]), this.fiterTime(this.dateRange[1])];
        console.log('转化时间', this.timeRange);
      }, 0)
    },
    fiterTime(value) {
      if (!value) return '';
      const date = new Date(value);
      const year = date.getFullYear();
      const month = (date.getMonth() + 1).toString().padStart(2, '0');
      const day = date.getDate().toString().padStart(2, '0');
      return `${year}-${month}-${day}`;
    },
    /** 查询用户列表 */
    getList() {
      this.loading = true;
      listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.tableDataList = response.rows;
          this.total = response.total;
          this.loading = false;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
  },
}
</script>


<style scoped lang="scss">
.timeType {
  display: flex;
  align-items: center;
  margin-right: 10px;

  li {
    border: 1px solid #eee;
    height: 32px;
    margin: 0;
    padding: 0 15px;
    list-style: none;
    cursor: pointer;

    &.active {
      border-color: #2d8cf0;
      color: #2d8cf0;
    }
  }
}

.time-big {
  display: flex;
  align-items: center;
}

.formGroup {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
}

.center-title {
  height: 30px;
  display: flex;
  align-items: center;

  span {
    content: "";
    width: 4px;
    height: 14px;
    background-color: #3070ff;
    display: block;
    margin-right: 5px;
  }
}

.tableAnalysis {
  padding-bottom: 20px;
  position: relative;

  .center-title {
    margin-bottom: 20px;
  }

  .exportData {
    position: absolute;
    right: 0px;
    top: 0px;

  }
}
.packageOrdersList {
padding: 16px;
}
.table-big {
  background: #fff;
  padding: 10px;
}
.search {
  display: flex;

  ::v-deep.el-input__inner {
    border-right: none !important;
    border-radius: 4px 0px 0px 0px;
  }

  ::v-deep .el-button--default {
    border-radius: 0px 4px 4px 0px;
    padding: 0px 10px;
  }
}
.status {
  padding: 2px 7px;
  background-color: rgb(0, 194, 112);
  display: inline-block;
  border-radius: 4px;
  font-size: 12px;
  color: #fff;
  &.red {
    background-color: rgb(251, 88, 78);
  }
}
.number-big {
  padding: 12px;
  background: #fff;
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  border-radius: 4px;
  .number {
    margin-right: 30px;
  }

}
.qrCode {
  width: 130px;
  margin: auto;
  display: flex;
  justify-content: center;
  flex-direction: column;
  .qrCode-img {
    width: 120px;
    margin-bottom: 20px;
  }
  img {
    width: 120px;
    margin-bottom: 20px;
  }
}
.title {
  font-size: 14px;
  display: flex;
  img {
    width: 26px;
    height: 26px;
  }
}
</style>
